#include <cstdio>

bool visit[ 20002 ];
int prime[ 3000 ], pcnt;
int f[ 20002 ];

void init( )
{
    int i, j, k;
    for ( i = 0; i <= 20000; i++ )
        visit[ i ] = 1;
    for ( i = 2; i <= 10000; i++ )
        for ( j = i; j * i <= 20000; j++ )
            visit[ i * j ] = 0;
    visit[ 0 ] = visit[ 1 ] = visit[ 2 ] = 0;
    for ( i = 3, pcnt = 0; i <= 20000; i++ )
        if ( visit[ i ] ) prime[ pcnt++ ] = i;
    for ( i = 0; i < pcnt; i++ )
        for ( j = i + 1; j < pcnt && prime[ i ] + prime[ j ] <= 20000; j++ )
            f[ prime[ i ] + prime[ j ] ]++;
    for ( i = 3; i <= 20000; i += 2 )
    {
        for ( j = 0; j < pcnt && prime[ j ] < i; j++ )
        {
            f[ i ] += f[ i - prime[ j ] ];
            if ( i - prime[ j ] > prime[ j ] && visit[ i - 2 * prime[ j ] ] && i != 3 * prime[ j ] ) f[ i ]--;
        }
        f[ i ] /= 3;
    }
}

int main( )
{
    int n;
    init( );
    while ( scanf("%d", &n) != EOF )
        printf("%d\n", f[ n ]);
    return 0;
}
